package services

import (
	"cloud-navigation/app/models"
	"cloud-navigation/global"
	"cloud-navigation/utils"
	"strconv"

	"github.com/gin-gonic/gin"
)

type Logs struct {
}

// 写入日志
func WriteLogs(c *gin.Context, message string, uid int) {
	if uid == 0 {
		uid, _ = strconv.Atoi(c.Keys["id"].(string))
	}
	global.App.DB.Create(&models.AdminLogs{
		IP:      utils.GetRealIP(c),
		Router:  c.Request.URL.Path,
		AdminID: uint(uid),
		Message: message,
	})
}
